<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:height="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>合作伙伴账务情况</title>
    <link rel="stylesheet" type="text/css" href="/themes/default/easyui.css" id="swicth-style">
    <link rel="stylesheet" type="text/css" href="/css/icon.css">
    <link rel="stylesheet" type="text/css" href="/css/common.css">
    <link rel="stylesheet" type="text/css" href="/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="/themes/color.css">
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/js/jquery.cookie.js"></script>
    <script type="text/javascript" src="/js/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/js/common.js"></script>
</head>

<body class="easyui-layout" style="padding:5px">
<fieldset>
    <legend>信息查询</legend>
    <form id="ffSearch" method="post">
        <div id="searchBar">
            <table cellspacing="0" cellpadding="0">
                <tr>
                    <th>账户类型：</th>
                    <td style="width:120px"><input id="accountId" name="accountId" type="hidden"/>
                        <select name="account_type" class="easyui-combobox" id="account_type">
                            <option value="" selected>全部</option>
                            <option value="1">平台账户</option>
                            <option value="2">充值账户</option>
                            <option value="3">收益账户</option>
                            <option value="4">网间账户</option>
                        </select>
                    </td>
                    <td colspan="2">
                        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search'"
                           onclick="onSearch()">查询</a>&nbsp;&nbsp;
                        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-clear'"
                           onclick="onClear()">重置</a>
                    </td>
                    <td align="right" width="800px" >
                        <div >
                            <table width="600px">
                                <th width="120px">平台账户余额：</th>
                                <td align="left" width="100px"><span  id="platform" width="120px">1</span></td>
                                <th width="120px" >充值账户余额：</th>
                                <td align="left"width="100px"><span  id="recharge" width="120px">3</span></td>
                                <th width="120px">收益账户余额：</th>
                                <td align="left" width="100px"><span  id="profit" width="120px" >4</span></td>
                                <th width="120px">网间账户余额：</th>
                                <td align="left" width="100px"><span  id="internet" width="120px">5</span></td>
                            </table>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</fieldset>
<div id="tabtab" class="easyui-tabs">
    <div title="入账详情">
        <table id="rechargeDG" >
        </table>
    </div>
    <div title="出账详情" width="100%" height="100%">
        <table id="consumeDG">
        </table>
    </div>
</div>
<script type="text/javascript">
    $(function(){
    var accountID ;
        $.ajax({
            type: "get",
            url: '/v1/api0/Account/getCurrentAccount',
            success:function(data){
            var account = data.body;
            $('#platform').text(account.balance);
            $('#recharge').text(account.recharge);
            $('#profit').text(account.profit);
            $('#internet').text(account.internet);
            $('#accountId').val(account.id);
            accountID = account.id;
            }
        });


        $('#account_type').combobox({
            onSelect:function(){
                onSearch();
            }
        });


        queryParams = $('#ffSearch').serializeObject();
        var dg1 = $('#rechargeDG').datagrid();
        dg1.datagrid({
            url:'/v1/api0/recharge_Record/list',
            queryParams:queryParams,
            columns:[[
                {field:'name',title:'充值名称',width:60},
                {field:'status',title:'状态',width:60,formatter: function(value,row,index){
                    switch(value) {
                        case 1: return "已完成";
                        case 2: return "进行中";
                    }
                }},
                {field:'sequenceNumber',title:'序列号',hidden:true},
                {field:'createTime',title:'创建时间',width:60,formatter: formatDateTime },
                {field:'updateTime',title:'更新时间',width:100,formatter: formatDateTime},
                {field:'creater',title:'创建人',width:100},
                {field:'createrId',title:'创建人ID',hidden:true},
                {field:'amount',title:'充值金额',width:100},
                {field:'recharge_method',title:'充值方式',width:100},
                {field:'type',title:'充值类型',width:100,hidden:true},
                {field:'remarks',title:'备注',width:100},
                {field:'accountId',title:'账户ID',hidden:true}
            ]],
            pagination: true,
            iconCls: 'icon-application_view_detail',
            singleSelect: true
        });

        $('#tabtab').tabs({
        onSelect:function(){
        var tab = $('#tabtab').tabs('getSelected');
        var index = $('#tabtab').tabs('getTabIndex',tab);
           if(index==0){
                $("#rechargeDG").datagrid("reload");
           }else if(index==1){
                queryParams = $('#ffSearch').serializeObject();
                var dg2 = $('#consumeDG').datagrid();
                    dg2.datagrid({
                        url:'/v1/api0/consume_Record/list',
                        queryParams:queryParams,
                        columns:[[
                        {field:'name',title:'消费名称',width:60},
                        {field:'status',title:'状态',width:60,formatter: function(value,row,index){
                         switch(value) {
                            case 1: return "已完成";
                            case 2: return "进行中";
                         }
                 }},
                {field:'sequenceNumber',title:'序列号',hidden:true},
                {field:'createTime',title:'创建时间',width:60},
                {field:'updateTime',title:'更新时间',width:100},
                {field:'creater',title:'创建人',width:100},
                {field:'createrId',title:'创建人ID',hidden:true},
                {field:'amount',title:'消费金额',width:100},
                {field:'consumeMethod',title:'消费方式',width:100},
                {field:'type',title:'消费类型',width:100},
                {field:'remarks',title:'备注',width:100},
                {field:'accountId',title:'账户ID',hidden:true}
            ]],
            pagination: true,
            iconCls: 'icon-application_view_detail',
            singleSelect: true
        });
           }
           }
        });
    });



    function onSearch(){
        var queryParams = $('#ffSearch').serializeObject();
        var tab = $('#tabtab').tabs('getSelected');
        var index = $('#tabtab').tabs('getTabIndex',tab);
        if(index==0){
        $('#rechargeDG').datagrid({
            url:'/v1/api0/recharge_Record/list',
            queryParams: queryParams
        });
        }else if(index==1){
        $('#consumeDG').datagrid({
            url:'/v1/api0/consume_Record/list',
            queryParams: queryParams
        });
        }
    }

    function onClear() {
        $('#ffSearch').form('clear');
        $('#account_type').combobox('setValue', '');
        $('#accountId').val(accountID);
        onSearch();
    }


</script>
</body>
</html>
